package com.weishi.project.speedometer.vo;

import com.weishi.common.utils.DateUtils;
import com.weishi.common.utils.StringUtils;
import lombok.Data;

import java.util.Date;

@Data
public class DevInfo {

    /**
     * 设备唯一标识
     */
    private String devId;

    /**
     * 设备状态
     */
    private int status;

    /**
     * 设备在线唯一距离
     */
    private double distance;

    /**
     * 设备gps速度
     */
    private double speed;

    /**
     * 桨频计算方式 0、加速度 1、角度
     */
    private int propellerFrequencyFlag;

    /**
     * 设备每桨的每分钟平均频率（桨频）
     */
    private int propellerFrequency;

    /**
     * 航道Id
     */
    private int channelId;

    /**
     * 数据标识
     */
    private String msgId = "replyClient";

    /**
     * 行程开始时间
     */
    private String startTime = "";

    /**
     * 行程结束时间
     */
    private String endTime = "";

    /**
     * 实时时间
     */
    private String realTime;

    public void setRealTime(){
        if(StringUtils.isEmpty(this.startTime)){
            this.realTime = "0:0:0";
        }else{
            long start = DateUtils.parseDate(this.startTime).getTime();
            long end = 0;
            if(StringUtils.isEmpty(this.endTime)){
                end = new Date().getTime();
            }else{
                end = DateUtils.parseDate(this.endTime).getTime();
            }

            this.realTime =  DateUtils.getStringTime(end-start);

        }

    }

    @Override
    public String toString() {
        return "{" +
                "devId:'" + devId + '\'' +
                ", status:" + status +
                ", distance:" + distance +
                ", speed:" + speed +
                ", propellerFrequency:" + propellerFrequency +
                ", startTime:'" + startTime + '\'' +
                ", endTime:'" + endTime + '\'' +
                ", realTime:'" + realTime + '\'' +
                '}';
    }
}
